import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';
import 'package:honeypotflutter/publicBussine/bussine_image.dart';
import '../pages/deliver_order/logic.dart';

class DeliverOrderExpress extends StatelessWidget {
  DeliverOrderExpress({super.key});
  final DeliverOrderLogic _logic = Get.find<DeliverOrderLogic>();
  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(top: 20),
      child: Column(
        children: [
          Text(
            "运单扫描",
            style: TextStyle(
              color: MGColors.text1Color,
              fontSize: MGFont.textFont1,
              fontWeight: FontWeight.bold,
            ),
          ),
          SizedBox(height: 5),
          Row(
            children: [
              Image.asset(MGImage.image("express_default", type: ImagePathType.express), width: 30),
              SizedBox(width: 10),
              Expanded(
                  child: InkWell(
                onTap: _logic.selectExpress,
                child: GetBuilder<DeliverOrderLogic>(
                    init: DeliverOrderLogic(),
                    builder: (controller) {
                      return Text(
                        (controller.open.value && controller.orderInfoModel.courierCompanyName != null) ? controller.orderInfoModel.courierCompanyName! : "扫描单号后自动匹配",
                        style: TextStyle(
                          color: (_logic.open.value && controller.orderInfoModel.courierCompanyName != null) ? MGColors.text1Color : MGColors.text3Color,
                          fontSize: MGFont.textFont1,
                        ),
                      );
                    }),
              )),
              Obx(() => CupertinoSwitch(
                  value: _logic.open.value,
                  onChanged: (value) {
                    _logic.open.value = value;
                    _logic.update();
                  }))
            ],
          )
        ],
        crossAxisAlignment: CrossAxisAlignment.start,
      ),
    );
  }
}
